home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: netcom.com!smryan
- From: smryan@netcom.com (@#$%!?!)
- Subject: Re: Pointer to Functions and Calls thereof??
- Message-ID: <smryanDq0EEM.A9L@netcom.com>
- Organization: The Programmer formerly known as S M Ryan
- X-Newsreader: TIN [version 1.2 PL1]
- References: <Dq01Ft.Dqn@latcs1.lat.oz.au>
- Date: Wed, 17 Apr 1996 13:49:34 GMT
- Sender: smryan@netcom5.netcom.com
-
- : void func1(void){naughty bits}
- : void func2(void){naughty bits}
-
- : void main(void)
- : { void *a[1];
-
- : a[1]=func1;
- : a[2]=func2;
-
- These cast (void (*)(void)) to (void*) before
- assigning to a.
-
- And the only valid subscript of a is [0].
-
- : (*a[1])();
-
- (*a[1]) has type (void) so appending a call list
- doesn't make too much sense.
-
- : }
-
- Perhaps
- typedef void (*funcptr)(void);
- funcptr a[2];
-
- a[0] = func1;
- a[1] = func2;
-
- (*a[0])();
-
- --
- The Queen who loves, the Queen of life, | smryan@netcom.com PO Box 1563
- the Queen who straits, the Queen of strife;| Cupertino, California
- with gasp of death or gift of breath | (xxx)xxx-xxxx 95015
- she brings the choice of birth or knife. | I don't use no smileys
-